<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= web_title%></title>
    <link rel="stylesheet" href="/libs/Tree/layui_ext/dtree/dtree.css">
    <link rel="stylesheet" href="/libs/Tree/layui_ext/dtree/font/dtreefont.css">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/ruoling/css/ruoling-ui.css">
    <link rel="stylesheet" href="/ruoling/css/ruoling-load.css">
</head>
<style>
    /* chrome */
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }
    /* 火狐浏览器 */
    input[type="number"] {
        -moz-appearance: textfield;
    }

    .Yiling-flexd{position: fixed;bottom: 0;background-color: #f0f4f7;width: 100%;border-top: 1px #c7c7c7 solid;text-align: right;}
    .Yiling-padding{padding: 20px 15px;}
    .Yiling-border-blue{border: 1px solid #0064b6;}
    .Yiling-border-block{border: 1px solid #000;}
    .Yiling-Body{background-color: #ffffff;}
    .Yiling-padding-bottom{padding-bottom: 15px;}
    .Yiling-seach{display: inline-block;height: 36px;border: 1px solid #e5e6e7;vertical-align: top;line-height: 36px;width: 36px;text-align: center;margin-left: -6px;border-top-right-radius: 5px;border-bottom-right-radius: 5px;cursor: pointer;}
    .Yiling-tree-border{border: 1px solid #e5e6e7;border-radius: 4px;padding: 2px;overflow-y: auto;height: 250px;}
</style>
<body class="Yiling-Body">
    <form class="layui-form" action="">
        <div style="padding:20px 20px;">
            <div class="Yiling-padding-bottom">
                <label class="layui-form-label" style="width: 190px;"><i style="color: red;">*  </i>字典名称：</label>
                <div style="width: 300px;display: inline-block;">
                    <input type="text" name="sys_dict_name"  required  lay-verify="required" placeholder="请输入字典名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="Yiling-padding-bottom">
                <label class="layui-form-label" style="width: 190px;"><i style="color: red;">*  </i>字典类型：</label>
                <div style="width: 300px;display: inline-block;">
                    <input type="text" name="sys_dict_datatype"  required  lay-verify="required" placeholder="请输入字典类型" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="Yiling-padding-bottom">
                <label class="layui-form-label" style="width: 190px;"><i style="color: red;">*  </i>是否启用：</label>
                <div style="width: 300px;display: inline-block;">
                    <input type="checkbox" name="sys_dict_status" value="1" title="开启" checked>
                </div>
            </div>
            <div class="Yiling-padding-bottom">
                <label class="layui-form-label" style="width: 190px;"><i style="color: red;">*  </i>备注：</label>
                <div style="width: 300px;display: inline-block;">
                    <textarea name="sys_dict_remark" placeholder="请输入备注内容" class="layui-textarea"></textarea>
                </div>
            </div>
        </div>
        <div class="Yiling-flexd">
            <div class="Yiling-padding">
                <button type="button"  lay-submit lay-filter="formDemo"  class="layui-btn layui-btn-sm Yliing-blue Yiling-border-blue">确认</button>
                <button type="button" id="Yiling-close" class="layui-btn layui-btn-sm layui-btn-primary  Yiling-border-block">关闭</button>
            </div>
        </div>
    </form>  
</body>
</html>
<script src="/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
    base:""
}).extend({
    Yiling:"/libs/ruoling-request/js/Yiling-Request"
}).use(["table","layer","jquery","form","Yiling"],function(){
    let table = layui.table;
    let layer = layui.layer;
    let $ = layui.jquery;
    let form = layui.form;
    let request = layui.Yiling.YI_Ajax;

    //监听提交
    form.on('submit(formDemo)', function(data){

        layer.confirm('是否确认添加', {icon: 3, title:'提示'}, function(index){
            data.field.sys_dict_status = data.field.sys_dict_status == undefined ? 0 : 1;
            let obj = {
                sys_dict_status: data.field.sys_dict_status,
                sys_dict_name:data.field.sys_dict_name,
                sys_dict_datatype:data.field.sys_dict_datatype,
                sys_dict_remark:data.field.sys_dict_remark,
            }
            new request().SetUrl("/admin/v1/api/dicttype/add").SetType("POST").SetDataPara(obj).Alone().Init(function(result){
                    parent.window.LoadTable();
                    ifaremClose();
            })
            layer.close(index);
        });
        return false;
    });
      // 关闭按钮事件
    let Yiling_close = document.querySelector("#Yiling-close");
    Yiling_close.addEventListener("click",function(){
        ifaremClose();
    });

    function ifaremClose(){
         //获取特定iframe层的索引
         let index = parent.layer.getFrameIndex(window.name);  
            parent.layer.close(index);
    };
})
</script>
<!-- 时间格式化 -->
<script type="text/html" id="SetDateCrete">
    {{FormDate(d.creationtime,"yyyy年MM月dd日 HH:mm:ss")}}
</script>
<!-- 时间格式化 -->
<script type="text/html" id="SetDateCrete1">
    {{FormDate(d.endtime,"yyyy年MM月dd日 HH:mm:ss")}}
</script>

<script>
    function FormDate(d,str){
        return layui.util.toDateString(d, str)
    }

</script>